home *** CD-ROM | disk | FTP | other *** search
/ Vypalování CD / Vypalovani-CD-cd1.bin / CDWriter ActiveX Control 1.4 / CDWriterXP.exe / {app} / Sample1 / Globals.bas < prev    next >
BASIC Source File  |  2002-02-17  |  9KB  |  193 lines

  1. Attribute VB_Name = "Globals"
  2. Option Explicit
  3. Public Function GetWriteErrorMessage(ByRef objCDR As CDWriterXP, ByVal WriteError As CDWriterXPLib.eWriteError, ByVal DeviceError As CDWriterXPLib.eCDError) As String
  4.  
  5.     'This function will build a string to display the error to the user
  6.     Dim strError As String
  7.     
  8.     'Show the correct error message
  9.     Select Case WriteError
  10.     Case errDriveError
  11.         'If there is a drive error, you can retrieve the exact DeviceError
  12.         'Including exact Error sense data from the drive. GetLastError gives an enum
  13.         'of the error.GetErrorData returns a string representing the actual error data
  14.         'returned from the device
  15.         'Use the object browser to find the corresponding eWriteError to determine the error more thouroughly
  16.         'We will handle the unknow here
  17.         If DeviceError = cdUnknownError Then
  18.             strError = "An unknown device error has occurred (" & CStr(DeviceError) & ")." & vbCrLf & _
  19.                         "Extended Error Data - " & objCDR.GetErrorData()
  20.         Else
  21.             strError = GetDeviceErrorMsg(DeviceError)
  22.         End If
  23.                 
  24.     Case errFileError
  25.         'File Error - details raised previously in TrackFileError event
  26.         strError = "A file error was encountered while writing the disc."
  27.     
  28.     Case errInvalidFormat
  29.         'One of the tracks were added to the queue with an invalid format
  30.         strError = "Tracks have been added the disc image with an invalid format...Please try again."
  31.         
  32.     Case errNoTracksQueued
  33.         'No tracks were added to the queue
  34.         strError = "Tracks have been added the disc image...Please add tracks and try again."
  35.     
  36.     Case errReadBufferInitFailed
  37.         strError = "The read buffer could not be initialized...check your memory/disc resources."
  38.         
  39.     Case errWriteBufferInitFailed
  40.         strError = "The write buffer could not be initialized...check your memory/disc resources."
  41.     
  42.     Case Else
  43.         'Should never get here
  44.         strError = "Unknown writing error."
  45.     End Select
  46.     
  47.     'Return the error message
  48.     GetWriteErrorMessage = strError
  49.     
  50. End Function
  51. Public Function GetFileErrorMessage(ByVal FileError As CDWriterXPLib.eTrackFileError, ByVal FileName As String)
  52.     Dim strErrorMsg As String
  53.     
  54.     'This function will handle the file error
  55.     Select Case FileError
  56.     Case tfeFileBufferError
  57.         strErrorMsg = "Error buffering file: " & FileName
  58.     Case tfeFileOpenError
  59.         strErrorMsg = "Error opening file: " & FileName
  60.     Case tfeFileReadError
  61.         strErrorMsg = "Error reading file: " & FileName
  62.     Case tfeFileWriteError
  63.         strErrorMsg = "Error writing file: " & FileName
  64.     Case Else
  65.         strErrorMsg = "Unknown file error!:"
  66.     End Select
  67.     
  68.     'Return error message
  69.     GetFileErrorMessage = strErrorMsg
  70. End Function
  71. Private Function GetDeviceErrorMsg(ByVal DeviceError As CDWriterXPLib.eCDError) As String
  72.     Dim strMsg As String
  73.         
  74.     'Get a String which explains the error code as explained in the help files
  75.     Select Case DeviceError
  76.     Case cdNoAdditionalErrorData '1000
  77.         strMsg = "No additional error data was reported"
  78.     Case cdIOTerminated '1001
  79.         strMsg = "Abnormal I/O Termination"
  80.     Case cdLogicalUnitNotReady '1002
  81.         strMsg = "The drive is not ready"
  82.     Case cdLogicalUnitCommFailed '1003
  83.         strMsg = "Communication with drive unit failed"
  84.     Case cdDeviceTrackingError '1004
  85.         strMsg = "The drive could not track properly"
  86.     Case cdWriteGenericError '1005
  87.         strMsg = "Writing error of unknown origin"
  88.     Case cdWriteRecoveryNeeded '1006
  89.         strMsg = "Writing occurred, but recovery is needed"
  90.     Case cdWriteRecoveryFailed '1007
  91.         strMsg = "Recovery attempt failed"
  92.     Case cdWriteLossOfStreaming '1008
  93.         strMsg = "A buffer under-run has occurred"
  94.     Case cdReadUnrecovered '1009
  95.         strMsg = "The disc could not be read"
  96.     Case cdReadRetriesExhausted '1010
  97.         strMsg = "The drive's attempts at reading retries failed"
  98.     Case cdReadErrorTooLong '1011
  99.         strMsg = "The read timed out"
  100.     Case cdReadLECUncorrectable '1012
  101.         strMsg = "While reading, the LEC was not recovered"
  102.     Case cdReadCIRCUnrecovered '1013
  103.         strMsg = "The CIRC could not be validated"
  104.     Case cdReadUPCEANFailed '1014
  105.         strMsg = "Reading of the UPC failed"
  106.     Case cdReadISRCFailed '1015
  107.         strMsg = "Reading of the ISRC failed"
  108.     Case cdReadLossOfStreaming '1016
  109.         strMsg = "Streaming while reading was interrupted"
  110.     Case cdPositioningError '1017
  111.         strMsg = "Drive could not position media"
  112.     Case cdParameterListLengthError '1018
  113.         strMsg = "An incompatible parameter length was sent to the drive"
  114.     Case cdSynchronousTransferError '1019
  115.         strMsg = "A transfer error occurred to the drive"
  116.     Case cdInvalidCommandCode '1020
  117.         strMsg = "An invalid command was sent to the drive"
  118.     Case cdLBAOutOfRange '1021
  119.         strMsg = "Error trying to write past the end of the media"
  120.     Case cdInvalidCDBField '1022
  121.         strMsg = "Invalid command field"
  122.     Case cdInvalidParamterListField '1023
  123.         strMsg = "An incompatible parameter field was sent to the drive"
  124.     Case cdParameterNotSupported '1024
  125.         strMsg = "A command parameter is not supported"
  126.     Case cdParamterValueInvalid '1025
  127.         strMsg = "A command parameter had an invalid value"
  128.     Case cdBusOrDeviceReset '1026
  129.         strMsg = "The SCSI/ATAPI bus was reset and caused a write failure"
  130.     Case cdParametersChanged '1027
  131.         strMsg = "A command parameter changed while in progress"
  132.     Case cdIncompatibleMedium '1028
  133.         strMsg = "The disc is not compatible with the drive mode"
  134.     Case cdReadUnknownMediumFormat '1029
  135.         strMsg = "The drive does not recognize the format of the disc"
  136.     Case cdReadIncompatibleMediumFormat '1030
  137.         strMsg = "The disc format is not compatible with the drive"
  138.     Case cdWriteUnknownMediumFormat '1031
  139.         strMsg = "The disc is of an unknown format"
  140.     Case cdIncompatibleWriteFormat '1032
  141.         strMsg = "The drive cannot write because of an incompatible format"
  142.     Case cdMediaNotPresent '1033
  143.         strMsg = "A disc is not present"
  144.     Case cdLogicalUnitFailure '1034
  145.         strMsg = "The drive had an unknown failure"
  146.     Case cdLogicalUnitTimedOut '1035
  147.         strMsg = "The drive has timed out while completing a command"
  148.     Case cdEraseFailed '1036
  149.         strMsg = "The disc could not be erased"
  150.     Case cdUnableToRecoverTOC '1037
  151.         strMsg = "The Table of Contents is unrecoverable"
  152.     Case cdEndOfUserAreaOnTrack '1038
  153.         strMsg = "Error trying to write past the user area of the media"
  154.     Case cdPacketDoesNotFit '1039
  155.         strMsg = "Packet recording is not configured correctly"
  156.     Case cdIllegalTrackMode '1040
  157.         strMsg = "The current track mode is incompatible with the disc format"
  158.     Case cdInvalidPacketSize '1041
  159.         strMsg = "Packet recording has incorrect size"
  160.     Case cdSessionFixationError '1042
  161.         strMsg = "A generic session closing error occurred"
  162.     Case cdSessionFixationErrorLeadIn '1043
  163.         strMsg = "Error closing Lead-in area"
  164.     Case cdSessionFixationErrorLeadOut '1044
  165.         strMsg = "Error closing Lead-out area"
  166.     Case cdSessionFixationIncompleteTrack '1045
  167.         strMsg = "While closing, the track was never completed"
  168.     Case cdEmptyPartialReservedTrack '1046
  169.         strMsg = "Error attempting to write to a reserved track"
  170.     Case cdPowerCalibrationFull '1047
  171.         strMsg = "Power calibration area is full"
  172.     Case cdPowerCalibrationAreaError '1048
  173.         strMsg = "A flaw exists in the Power calibration area"
  174.     Case cdPMAUpdateFailure '1049
  175.         strMsg = "The disc's PMA could not be updated"
  176.     Case cdPMAFull '1050
  177.         strMsg = "The disc's PMA is full"
  178.     Case cdUnknownError '1051
  179.         strMsg = "Unknown error - use extended data for more information"
  180.     Case cdNoError '1052 - You will never see this most likely
  181.         strMsg = "No Error Reported"
  182.     Case cdNoSeekComplete '1053
  183.         strMsg = "A seek command was interrupted by another command"
  184.     End Select
  185.     
  186.     'return the error string
  187.     strMsg = strMsg & " (" & CStr(DeviceError) & ")."
  188.     
  189.     GetDeviceErrorMsg = strMsg
  190.     
  191. End Function
  192.  
  193.